<?php 
/**
 * 词条例子操作
 DROP TABLE IF EXISTS `dict_example`;
CREATE TABLE `dict_example` (
  `e_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `i_id` int(10) unsigned NOT NULL,
  `sentence` varchar(255) DEFAULT NULL,
  `definition` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`e_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 */
Class ExampleModel extends Model{
  /**
   * 根据例子id返回例子信息
   * @param  int    $e_id [description]
   * @return [type]       [description]
   */
  public function selectExampleByEid(int $e_id)
  {
    return $this->where('e_id=' . $e_id)->find();
  }

  public function selectExampleByIid(int $i_id)
  {
    return $this->where('i_id=' . $i_id)->select();
  }

  public function addExample($data)
  {
    return $this->add($data);
  }

  public function delExampleByEid(int $e_id)
  {
    return $this->where('e_id=' . $e_id)->delete();
  }

  public function updateExample($data)
  {
    return $this->save($data);
  }

  public function delExampleByIid(int $i_id)
  {
    return $this->where('i_id=' . $i_id)->delete();
  }

  public function delExampleByDid(int $d_id)
  {
    return $this->where("i_id in (select i_id from dict_item where d_id = $d_id)")->delete();
  }
  
}
 ?>